package com.group.itms.routes.map;

import java.util.ArrayList;
import java.util.List;

import com.group.itms.routes.map.Layer.Type;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.RectF;

public class OfflineMapWrapper implements Map {

	private Context mContext;
	private int mMyLocationIconId;
	private Bitmap mMyLocationBmp;
	
	private OfflineMap mInternalMap;
	
	public OfflineMapWrapper(Context ctx) {
		mContext = ctx;
	}
	
	
	private List<Layer> getleLayersOfType(Type t) {
		List<Layer> layers = new ArrayList<Layer>();
		List<Layer> ls = mInternalMap.getLayers();
		for (Layer l : ls) {
			if (l.getType().equals(t)) {
				layers.add(l);
			}
		}
		return layers;
	}
	
	@Override
	public void setMapInternal(Object map) {
		if (map instanceof OfflineMap) {
			mInternalMap = (OfflineMap) map;
		} else {
			throw new IllegalArgumentException(
					"This implementation only accepts, OfflineMap");
		}
	}

	@Override
	public void setMyLocation() {
		
	}

	@Override
	public void addLayer(Layer layer) {
		if (mInternalMap != null) {
			mInternalMap.addLayer(layer);
		}
	}

	@Override
	public void removeLayer(Layer layer) {
		if (mInternalMap != null) {
			mInternalMap.removeLayer(layer);
		}
	}

	@Override
	public void removeAllLayer() {

	}

	@Override
	public IMarker addMarker(double x, double y, int icId, Layer layer) {
		return null;
	}

	@Override
	public void setLayerVisibility(Layer layer, boolean visible) {
		Type type = layer.getType();
		setLayerTypeVisibility(type, visible);
	}
	
	@Override
	public void setLayerTypeVisibility(Type type, boolean visible) {
		List<Layer> layers = getleLayersOfType(type);
		mInternalMap.setRedrawView(false);
		for (Layer l : layers) {
			l.setVisible(visible);
		}
		mInternalMap.setRedrawView(true);
		mInternalMap.redrawView();
	}

	@Override
	public void goToMyLocation() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void traceMyLocation(boolean yesNo, int period) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void clearMap() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void drawOnMap() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void reDraw() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void setLayersChangedListener() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public LayersChangedListener getLayersChangedListener() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void setZoom(float zoom) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void addLayers(List<Layer> layers) {
		if (mInternalMap != null) {
			mInternalMap.addLayers(layers);
		}
	}


	@Override
	public void setBounds(Bounds bounds) {
		// TODO Auto-generated method stub
		
	}


	@Override
	public void goToRoutes() {
		// TODO Auto-generated method stub
		
	}


	@Override
	public void setMapType(MapType type) {
		// TODO Auto-generated method stub
		
	}

}
